import { Component, Inject } from '@angular/core';
import { IonicPage, NavController, ModalController} from 'ionic-angular';

// service
import { LoadingService } from '../../providers/utils/loading.service';
import { ToastService } from '../../providers/utils/toast.service';
import { AlertService } from '../../providers/utils/alert.service';

// 图片查看
import { GalleryModal } from 'ionic-gallery-modal';

// picker选择
import { convertEnumToColumn } from 'ion-multi-picker';
// 枚举
enum Fruit {
  Apple, Orange, Melon, Banana, Pear,Test01,Test02
}

/*** 测试页面
 * */
@IonicPage()
@Component({
    templateUrl: 'test.html'
})
export class TestPage {

    public event = {
      month: '1994-02-19',
    };
    fruits: any[];
    fruit: Fruit;
    Fruit;

    imagePaths: Array<string> = [];

    frontCardUrl: string = '';
    backCardUrl: string = '';

    constructor(
      private navCtrl: NavController,
      public modalCtrl: ModalController,
      private toastCtrl: ToastService,
      private alertCtrl : AlertService,
      private loadingCtrl : LoadingService,
      @Inject('auth') private authService,
    )
    {
      this.fruit = Fruit.Melon;
      this.Fruit = Fruit;
      this.fruits = convertEnumToColumn(this.Fruit);
    }

    presentLoading() {
      this.loadingCtrl.create('正在加载中..');
    }
    presentLoading2() {
      this.loadingCtrl.createOnlyContent('最多6张');
    }
    presentLoading3() {
      this.loadingCtrl.createLoading('正在加载中..');
    }

    // 弹框
    executeToastCtrl() {
      this.toastCtrl.create('haha输入密码不符输入密码不符输入密码不符输入密码不符输入密码不符!!!!!!!!!!!!!输入密码不符',true);
    }
    executeToastCtrl2() {
      this.toastCtrl.createCenterToast('输入密码不符输',100000000000);
    }


    // 打开弹框
    executeAgreeAlertCtrl()
    {
      this.alertCtrl.createAgreeAlert('网络中断2121212121212121212121212121212121212121212121').then((yes)=>{
        if(yes){
          this.toastCtrl.create("success!");
        }
      });
    }

    // 打开弹框
    executeDeleteAlertCtrl()
    {
      this.alertCtrl.createChangeAlert('请允许猴哥贷访问通讯录1222222222222222').then((yes)=>{
        if(yes){
          this.toastCtrl.create("success!");
        }
      });
    }
    // 打开弹框
    executeMessageAlertCtrl()
    {
      this.alertCtrl.createMessageAlert('请允许猴哥贷访问通讯录','张三<br>你说什么').then((yes)=>{
        if(yes){
          this.toastCtrl.create("success!");
        }
      });
    }
    // 打开弹框
  executeInputAlertCtrl()
    {
      this.alertCtrl.createFloatInputAlert('验证码已发送,请注意查收').then((data)=>{
        debugger;
        if(data){
          this.toastCtrl.create("success!");
        }
      });
    }

    // 打开图片预览
    executePhotoView()
    {
      this.createModal(GalleryModal,{
        photos: [
          {url:'assets/img/borrow-money/test01.png',type:''},
          {url:'assets/img/borrow-money/test02.png',type:''},
          {url:'assets/img/borrow-money/test03.png',type:''}
        ],
        initialSlide: 0
      })
    }

    /*** 创建modal
     * @param page 要到的位置
     * @param data 传输参数, 不传默认空
     * */
    private createModal(page: any,data: any= {})
    {
      let modal = this.modalCtrl.create(page, data,{
        showBackdrop: false,
        enableBackdropDismiss: false,
      });
      modal.present();
    }

    imagesSelected(event)
    {
      this.imagePaths = event.value;
    }
    /*** 身份证前面数据
    * */
    getFrontCard(event)
    {
      debugger;
      this.frontCardUrl = event.value.url;
    }
    resetFrontCard()
    {
      debugger;
      this.frontCardUrl = '';
    }
    /*** 身份证后面数据
   * */
    getBackCard(event)
    {
      debugger;
      this.backCardUrl = event.value.url;
    }

    resetBackCard()
    {
      debugger;
      this.backCardUrl = '';
    }

 }
